package Olivia.olivia3d.shader
{
	public class VertexShader
	{
		public var vsAgal:String =			
			"m44 op, va0, vc0 \n"+ 		// pos to clipspace
			"mov v0, va2\n"+			//  uv
			"m44 v1, va1, vc12\n" +		// normal变化
			"m44 v2, va0, vc8\n" +		// vc8 view坐标系
			"m44 v3, va0, vc4";			// vc12 world坐标系
		
				
		public function VertexShader()
		{
			
		}
		
		public static function withShadowVsAgal():String
		{
			return "m44 op, va0, vc0\n" +
				"mov v0, va2\n" +
				//light proj
				"m44 vt1, va0, vc16\n"+
				"rcp vt1.w, vt1.w\n" +
				//0.5 * vPosLight.xy / vPosLight.w + float2( 0.5, 0.5 );
				"mul vt1.xyz, vt1.xyz, vt1.w\n" +
				"mul vt1.xy, vt1.xy, vc20.xy\n" +
				"add vt1.xy, vt1.xy, vc20.xx\n" +
				"mov v1.xyz, vt1.xyz\n" +
				"mov v1.w, va0.w\n" +				
				"m44 v2, va1, vc12\n" +		// normal变化
				"m44 v3, va0, vc8\n" +		// vc8 view坐标系
				"m44 v4, va0, vc4";			// vc12 world坐标系
		}
		
		public static function withShadowVsAgalAni():String
		{
			return "m33 vt0.xyz, va0, vc[va3.x]\n"+		//m33 x mf
				"add vt0.x, vt0.x, vc[va3.x].w\n"+		//add tx
				"add vt1.x, va3.x, vc20.z\n"+
				"add vt0.y, vt0.y, vc[vt1.x].w\n"+		//add ty
				"add vt1.x, va3.x, vc20.w\n"+
				"add vt0.z, vt0.z, vc[vt1.x].w\n"+		//add tz
				"mov vt0.w, vc20.z\n"+
//				"m44 vt0, vt0, vc0\n"+
				//-------------ani------------- vt0 is new position
				"m44 op, vt0, vc0\n" +
				"mov v0, va2\n" +
				//light proj
				"m44 vt1, vt0, vc16\n"+
				"rcp vt1.w, vt1.w\n" +
				//0.5 * vPosLight.xy / vPosLight.w + float2( 0.5, 0.5 );
				"mul vt1.xyz, vt1.xyz, vt1.w\n" +
				"mul vt1.xy, vt1.xy, vc20.xy\n" +
				"add vt1.xy, vt1.xy, vc20.xx\n" +
				"mov v1.xyz, vt1.xyz\n" +
				"mov v1.w, vt0.w\n" +				
				"m44 v2, va1, vc12\n" +		// normal变化
				"m44 v3, vt0, vc8\n" +		// vc8 view坐标系
				"m44 v4, vt0, vc4";			// vc12 world坐标系
		}
		
		public static function depthVsAgal():String
		{
			return "m44 vt0, va0, vc0\n" +
				"mov op, vt0\n" +
				"mov v0, vt0";
		}
		
		public static function depthVsAgalAni():String
		{
			return "m33 vt0.xyz, va0, vc[va3.x]\n"+		//m33 x mf
				"add vt0.x, vt0.x, vc[va3.x].w\n"+		//add tx
				"add vt1.x, va3.x, vc4.x\n"+
				"add vt0.y, vt0.y, vc[vt1.x].w\n"+		//add ty
				"add vt1.x, va3.x, vc4.y\n"+
				"add vt0.z, vt0.z, vc[vt1.x].w\n"+		//add tz
				"mov vt0.w, vc4.x\n"+
				"m44 vt0, vt0, vc0\n"+
				"mov op, vt0\n" +
				"mov v0, vt0\n";
		}
		
		public static function pickVsAgal():String
		{
			return "m44 op, va0, vc0";
		}
		
		public static function pickVsAgalAni():String
		{
			return "m33 vt0.xyz, va0, vc[va3.x]\n"+		//m33 x mf
				"add vt0.x, vt0.x, vc[va3.x].w\n"+		//add tx
				"add vt1.x, va3.x, vc4.x\n"+
				"add vt0.y, vt0.y, vc[vt1.x].w\n"+		//add ty
				"add vt1.x, va3.x, vc4.y\n"+
				"add vt0.z, vt0.z, vc[vt1.x].w\n"+		//add tz
				"mov vt0.w, vc4.x\n"+
				"m44 op, vt0, vc0";
		}
	}
}